#pragma once

#include "../Gui.h"
#include "../Control/Text.h"

class CXMLParser;

enum  BroadcastType
{
    BC_VISIBLE,                            //Broadcast the visible window
    BC_ALL,                               //Broadcast all the window
    BC_VISIBLE_NOBASEEXPLORER               //Broadcast all the visible window, but no base explorer window as "DesktopExplorerWnd" and "HHTaskBar" 
};

class  GUI_API CUtil
{
public:
	static void		DeleteDirectory(const TCHAR *pszPath);
	static void		BroadcastMessage(BroadcastType bcType, UINT wMsg, WPARAM wParam,LPARAM lParam);
	static void		CreateDirectorySerial(TCHAR *pszPath);
	static BOOL		WCharToMByte(LPCWSTR lpcwszStr, LPSTR lpszStr, DWORD dwSize);
	static BOOL		MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize);
	static BOOL		CenterWindow(HWND hWnd);
	static int		GetScreenHeight();
	static int		GetScreenWidth();
	static wstring GetCurrentDirectory();
	static int		FindString(const TCHAR *szSource, const TCHAR *szFind,const int iBeginPos);
	static BOOL		Execute(const TCHAR *pszPath,TCHAR *pParameters = NULL);
	static BOOL		ShowTaskBar(BOOL bShow);
	static BOOL		InitResXML(CXMLParser &xml, wstring &strFileName,LPCWSTR pStrResType);
	static BOOL		TouchCalibrate();
	static int		GetOPIndexByValue(vector<Option>& ve,DWORD dwValue);
	static int		GetOPIndexByTxt(vector<Option>& ve,wstring strTxt);
	static BOOL		InitResHandle();
	static void		SetResPath( LPCTSTR pStr );
	static void		FreeResHandle();
	static HBITMAP	LoadBitmapEx(wstring strFileName,BOOL bFromDll);
	static wstring	GetResPath();
	static BOOL		GetFileExtension(wstring strFile,wstring& strExt);
	static BOOL		FindFile(list<wstring>& lst,wstring strPath,vector<wstring>& veFilter);
	static BOOL		EnumDir(list<wstring>& lst,wstring strPath);
	static void		TrimFileExtension(wstring& strFile);
	static void		TrimPathRight(wstring& strPath);
	static void		TrimPathLeft(wstring& strPath);

	static	wstring	GetStorageCardName();
	static	wstring	GetFlashName();
    static	HBITMAP	GetDCBmp(CDC *pDc);
	static	HBITMAP	GetScreenBmp();
	static  BOOL   PlayBeepSound(int nSound=500 ,int nDuration=100);
protected:
	static BOOL		EnumWindowsProcForBroadcast(HWND hWnd, LPARAM lParam );
  
    //It's for the BroadcastMessage function
	static HWND m_hWndBc;
	static UINT m_wMsgBc;
	static WPARAM m_wParamBc;
	static LPARAM m_lParamBc;
	static BroadcastType m_BcType;   

	static HMODULE g_ResDll;
	static wstring g_strResPath;

protected:
	CUtil(void);
	~CUtil(void);
};
